#ifndef QTMACHINE_H
#define QTMACHINE_H

/*******************************************************************************
  EmiSnes - Super Nintendo Entertainment System (TM) emulator for Symbian.

  EmiSnes is port of Snes9x see Snes9x headers for specific licence.

  Many thanks to the whole Snes9x team for the great work.

  EmiSnes is licenced under GPLv2.

  Copyright 2011 - 2016 Andre Botelho (andrebotelhomail@gmail.com)

  EmiSnes homepage: http://libproductions.wordpress.com/emisnes

  Permission to use, copy, modify and distribute EmiSnes in both binary and
  source form, for non-commercial purposes, is hereby granted without fee,
  providing that this license information and copyright notice appear with
  all copies and any derived work.

  This software source is provided 'as-is', without any express or implied
  warranty. In no event shall the authors be held liable for any damages
  arising from the use of this software.

  EmiSnes is freeware for PERSONAL USE only. Commercial users should
  seek permission of the copyright holder first. Commercial use includes
  charging money for EmiSnes or software derived from EmiSnes.

  The copyright holder request that bug fixes and improvements to the code
  should be forwarded to them so everyone can benefit from the modifications
  in future versions.

  Super NES and Super Nintendo Entertainment System are trademarks of
  Nintendo Co., Limited and its subsidiary companies.
*******************************************************************************/

/*******************************************************************
  THIS SOURCE IS BASED ON SNES4ALL CHUS'S WORK
  SEE http://chui.dcemu.co.uk/snes4all.html
*******************************************************************/

#include <Qt>
#include <QWidget>
#include <QTime>
#include <QEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QString>
#include <QMessageBox>
#include <QDebug>
#include "mainwindow.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <signal.h>
#include <errno.h>

#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <ctype.h>

#include "snes9x.h"
#include "memmap.h"
#include "debug.h"
#include "cpuexec.h"
#include "ppu.h"
#include "snapshot.h"
#include "apu.h"
#include "display.h"
#include "gfx.h"
#include "soundux.h"
#include "spc700.h"
#include "sa1.h"



#include "snescontroller.h"

#define AUTO_FRAMESKIP_DELAY 2
#define TH_VCOUNTER_SPLIT 11
#define SNES_MAX_MID_VCOUNTER (SNES_MAX_NTSC_VCOUNTER+((SNES_MAX_PAL_VCOUNTER-SNES_MAX_NTSC_VCOUNTER)/2))
#define TH_VCOUNTER0 ((TH_VCOUNTER_SPLIT*SNES_MAX_PAL_VCOUNTER)/10)
#define TH_VCOUNTER1 TH_VCOUNTER0
#define TH_VCOUNTER2 ((TH_VCOUNTER_SPLIT*SNES_MAX_MID_VCOUNTER)/10)
#define TH_VCOUNTER3 ((TH_VCOUNTER_SPLIT*SNES_MAX_NTSC_VCOUNTER)/10)
#define TH_VCOUNTER4 ((TH_VCOUNTER_SPLIT*240)/10)


unsigned snes4all_max_vcounter=TH_VCOUNTER0;
unsigned snes4all_apu_hmax=1;
long snes4all_vcounter[512];


int snes4all_frameskip=-1;
int snes4all_sound_enable=-1;
int snes4all_transparency=0;
int snes4all_throttle=0;
int snes4all_statesave=0;
int snes4all_stateload=0;
int snes4all_sound_rate=2;
int snes4all_sound_volume=2;
int snes4all_hires =0;
int snes4all_syncsound = -1;
int snes4all_intsound = -1;
int snes4all_framerate= 0;
int snes4all_stereo= 0;
int snes4all_sound_throttle=((1>>3)-1);
unsigned snes4all_timeslice=2+(3<<1);


int OldSkipFrame;

long reportf=0;

int MouseXpos=0;
int MouseYpos=0;
int MouseLbutton=0;
int MouseRbutton=0;
int SuperscopeTurbo=0;
int SuperscopeCursor=0;
quint32 MouseButton=0;

#define MUSIC_VOLUME 64

#define MAX_FRAMESKIP 6

char snes4all_image_file[1024];
int snes4all_emulating=0;
char *rom_filename;// = (char *)&snes4all_image_file[0];
char *snapshot_filename = NULL;

static uint32 joypad_val[8]={0x80000000,0x80000000,0x80000000,0x80000000,0x80000000,0x80000000,0x80000000,0x80000000};

void sound_disable_music(void);

#define dCPU(A) ((unsigned)(A))-((unsigned)&CPU)
#define dSA1(A) ((unsigned)(A))-((unsigned)&SA1)
#define dIAPU(A) ((unsigned)(A))-((unsigned)&IAPU)

#endif // QTMACHINE_H
